<?php

class Lang
{
    /**
     * Check to see whether the website use this language code
     * @param string $langCode
     * @return boolean
     */
    static public function has($langCode)
    {
        static $langList = null;

        if (null === $langList) {
            $langList = explode(',', Config::get('lang'));
        }

        if (false !== array_search($langCode, $langList)) {
            return true;
        }

        return false;
    }

    static public function getLang()
    {
        $l='';
        if($_GET['l']!='') {$l= d2v($_GET['l']); } else {$l= "en"; }
        if (isset($_COOKIE['l'])) {
            $l=$_COOKIE['l'];
        }
        else  if (isset($_SESSION['l'])) {
            $l=$_SESSION['l'];
        }
        return("langs/".$l.".php");
    }

    static public function addL()
    {	// Lay gia tri trong mang cua file langs lay ten nuoc theo ten rut gon
        global $lang;
        return fl('cn');
    }

    static public function getL()
    { // Lay gia tri trong mang cua file langs the hien ten nuoc bang so thu tu
        global $lang;
        return fl('nc');
    }

    static public function getCode()
    {
        static $lang = null;
        
        if (null === $lang) {
            if (isset($_COOKIE['lang'])) {
                $langCode = $_COOKIE['lang'];
                if ($langCode !== 'en') {
                    $langCode = 'vn';
                }
            } else {
                $langList = explode(',', Config::get('lang'));
                $langCode = $langList[0];
            }
            $lang = $langCode;
        }

        return $lang;
    }

    public static function getSupportGroup($group)
    {
        if(Lang::getCode() =='en')
        {
            switch ($group)
            {
                case 1: 	//-------------------------
                    return 'General Info';
                    break;
                case 2: 	//-------------------
                    return 'Bussiness';
                    break;
                case 3: 	//-------------------
                    return 'Human resource';
                    break;
                case 4: 	//-------------------
                    return 'Tech';
                    break;
                case 5: 	//-------------------
                    return 'Customer care';
                    break;
                default:
                    return 'Unknown group!';
            }
        }else
        {
            switch ($group)
            {
                case 1: 	//-------------------------
                    return 'Thông tin chung';
                    break;
                case 2: 	//-------------------
                    return 'Phòng kinh doanh';
                    break;
                case 3: 	//-------------------
                    return 'Phòng nhân sự';
                    break;
                case 4: 	//-------------------
                    return 'Phòng Kỹ thuật';
                    break;
                case 5: 	//-------------------
                    return 'Chăm sóc';
                    break;
                default:
                    return 'Unknow group!';
            }
        }

    }
}